#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() 
{
    char password[101];
    int n = 0;
    scanf("%d", &n);
    for (; n > 0; n--) 
    {
        scanf("%s", password);
        int i = 0;
        int flag = 1;
        int Letter = 0, letter = 0, num = 0;
        int len = 0;
        if (password[0] >= '0' && password[0] <= '9') 
        {
            flag = 0;
        }
        else 
        {
            for (i = 0; password[i] != '\0'; i++) 
            {
                len++;
                if (password[i] >= 'A' && password[i] <= 'Z') 
                {
                    Letter++;
                }
                else if (password[i] >= 'a' && password[i] <= 'z') 
                {
                    letter++;
                }
                else if (password[i] >= '0' && password[i] <= '9') 
                {
                    num++;
                }
                else 
                {
                    flag = 0;
                    break;
                }
            }
        }
        if (len >= 8 && flag &&((Letter && letter) || (Letter && num) || (letter && num))) 
        {
            printf("YES\n");
        }
        else 
        {
            printf("NO\n");
        }
    }
    return 0;
}